﻿/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A
 * copy of the license can be found at http://go.microsoft.com/fwlink/?LinkID=131993. If
 * you cannot locate the Microsoft Public License, please send an email to
 * mixon@microsoft.com. By using this source code in any fashion, you are agreeing to
 * be bound by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System;
using System.Windows;
using System.Windows.Controls;

namespace MIXOnline.Descry
{
    public partial class IsolatedStorageSizeDialog : UserControl
    {

        private Int64 _SizeInBytes;

        public Int64 SizeInBytes
        {
            get { return _SizeInBytes; }
            set
            {
                _SizeInBytes = value;
                buttonStorage.Content = "Increase Storage " + (_SizeInBytes / 1024 / 1024).ToString() + "Mb";
            }
        }

        public IsolatedStorageSizeDialog()
        {
            InitializeComponent();
            this.Visibility = Visibility.Collapsed;
        }

        public void Show()
        {
            this.Visibility = Visibility.Visible;
        }

        public void Hide()
        {
            this.Visibility = Visibility.Collapsed;
        }

        private void buttonStorage_Click(object sender, RoutedEventArgs e)
        {
            Storage.IncreaseQuota(_SizeInBytes);
            Hide();
        }

        private void buttonClose_Click(object sender, RoutedEventArgs e)
        {
            // user declines to increase size of Isolated Storage perist this so that user will not see dialog again. until cache is cleared.
            Storage.SetAppSettingItem("DeclinedStorageIncrease", true);
            Hide();
        }

        private void buttonStorageNo_Click(object sender, RoutedEventArgs e)
        {
            // user declines to increase size of Isolated Storage perist this so that user will not see dialog again. until cache is cleared.
            Storage.SetAppSettingItem("DeclinedStorageIncrease", true); 

            Hide();
        }
    }
}
